﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
//using JoeResume.Data;
//using JoeResume.Data.Repository;
using JoeResume.Model;

namespace JoeResume.Web.Controllers
{
    public class PersonalInfoController : ApiController
    {
        //private ResumeDbContext _context;

        public PersonalInfoController()
        {
                
        }

        public HttpResponseMessage Get()
        {
            //var repository = new PersonalInfoRepository(_context);
            //var personalInfos = repository.GetAll().ToArray();
            //_context = new ResumeDbContext();
            //var personalInfos = _context.PersonalInfos.ToArray();
            ////_context.Dispose();

            HttpResponseMessage msg = null;

            //msg = Request.CreateResponse<PersonalInfo[]>(HttpStatusCode.OK, personalInfos);

            msg = Request.CreateResponse(HttpStatusCode.OK);
            return msg;
        }

        public HttpResponseMessage Get(int id)
        {
            //var repository = new PersonalInfoRepository(_context);
            //var personalInfo = repository.GetById(id);
            //_context = new ResumeDbContext();
            //var personalInfo = _context.PersonalInfos.Find(id);
            //_context.Dispose();


            HttpResponseMessage msg = null;

            //msg = Request.CreateResponse<PersonalInfo>(HttpStatusCode.OK, personalInfo);
            msg = Request.CreateResponse(HttpStatusCode.OK);
            return msg;
        }

        [HttpPost]
        public void Update([FromBody]PersonalInfo personalInfo)
        {
            HttpResponseMessage msg = null;
            //_context = new ResumeDbContext();
            //var orig = _context.PersonalInfos.Find(personalInfo.Id);
            //_context.Entry(orig).CurrentValues.SetValues(personalInfo);
            //_context.SaveChanges();
            //_context.Dispose();

            //msg = Request.CreateResponse(HttpStatusCode.OK);
            //return msg;

            msg = Request.CreateResponse(HttpStatusCode.OK);
            return;
        }

        [HttpPut]
        public HttpResponseMessage Insert([FromBody]PersonalInfo personalInfo)
        {
            //_context = new ResumeDbContext();
            //_context.PersonalInfos.Add(personalInfo);
            //_context.SaveChanges();
            
            //return Request.CreateResponse(HttpStatusCode.Created, personalInfo);
            HttpResponseMessage msg = Request.CreateResponse(HttpStatusCode.OK);
            return msg;
        }
    }
}
